from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app

class HelloHandler(webapp.RequestHandler):
  def get(self):
    name = self.request.get('name')
    self.response.out.write('Hello ' + name)
    self.response.out.write("<a href = '/static/index.html'>My Index.html</a>")


class DiceHandler(webapp.RequestHandler):
  def get(self):
    times = self.request.get('times')

    import random

    DICE_ROLLS = 5

    # Simulate rolling two dice.
    dice_1 = random.randint(1, 6)
    dice_2 = random.randint(1, 6)
    self.response.out.write('Rolls:", dice_1, dice_2')
    if dice_1 ==1 and dice_2 ==1:
	self.response.out.write('snake eyes!')
    else:
          if dice_1 == dice_2:
		self.response.out.write('got double ' + str(dice_1) + "s")
	
class GoodbyeHandler(webapp.RequestHandler):
  def get(self):
    self.response.out.write('Gotta go now!')

def main():
  application = webapp.WSGIApplication([('/hello.*', HelloHandler),
					('/goodbye.*', GoodbyeHandler),
					('/dice.*', DiceHandler)],
                                       debug=True)
  run_wsgi_app(application)

if __name__ == '__main__':
  main()
